package com.cqhfan.api.clients.user.fallback;

import com.cqhfan.api.clients.user.UserClient;
import com.cqhfan.pojo.user.po.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;

import java.util.Collections;
import java.util.List;

/**
 * @author 眭传洪
 * @create 2025-07-26 2:35
 */
@Slf4j
public class UserClientFallbackFactory implements FallbackFactory<UserClient> {
    @Override
    public UserClient create(Throwable cause) {
        return new UserClient() {
            @Override
            public User getByUserName(String userName) {
                log.info("根据用户名调用用户服务获取用户失败");
                return null;
            }

            @Override
            public User getByUserPhone(String phone) {
                log.info("根据手机号调用用户服务获取用户失败");
                return null;
            }

            @Override
            public Long save(User user) {
                log.info("新增用户失败");
                return null;
            }

            @Override
            public List<User> listByIds(Iterable<Long> userIds) {
                log.info("批量获取用户信息失败");
                return Collections.emptyList();
            }
        };
    }
}
